﻿using System;
using System.Collections.Generic;
using System.Text;
using UtilZ.Dotnet.Ex.Model;

namespace UtilZ.Dotnet.Ex.Communication.Net.Web
{
    /// <summary>
    /// web序列化器接口
    /// </summary>
    public interface IWebSerializer
    {
       
        /// <summary>
        /// 将对象序列化为xml
        /// </summary>
        /// <param name="obj">要序列化的对象</param>
        /// <returns>xml</returns>
        string XmlSerialize(object obj);


        /// <summary>
        /// 将xml反序列化为指定类型的对象
        /// </summary>
        /// <param name="xml">xml</param>
        /// <param name="targetType">目标类型</param>
        /// <returns>结果对象</returns>
        object XmlDeserialize(string xml, Type targetType);




        /// <summary>
        /// 将对象序列化为json
        /// </summary>
        /// <param name="obj">要序列化的对象</param>
        /// <returns>json</returns>
        string JsonSerialize(object obj);

        /// <summary>
        /// 将json反序列化为指定类型的对象
        /// </summary>
        /// <param name="json">json</param>
        /// <param name="targetType">目标类型</param>
        /// <returns>结果对象</returns>
        object JsonDeserialize(string json, Type targetType);

    }
}
